package com.mytx.sso.config;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

//@ConfigurationProperties(prefix = "alipay")
@Configuration
public class AliPayConfig {
    /**
     * 应用ID,您的APPID，收款账号既是您的APPID对应支付宝账号
     */
    @Value("${alipay.appID}")
    public String APP_ID;

    /**
     * 商户私钥，您的PKCS8格式RSA2私钥
     */
    @Value("${alipay.privateKey}")
    public String PRIVATE_KEY;

    /**
     * 支付宝公钥
     */
    @Value("${alipay.alipayPublicKey}")
    public String ALI_PAY_PUBLIC_KEY;


    @Value("${alipay.grant_type}")
    public String GRANT_TYPE;

    /**
     * 签名方式
     */
    public String SIGN_TYPE = "RSA2";

    /**
     * 网关
     */
    @Value("${alipay.serviceUrl}")
    public String SERVICE_URL;


    /**
     * 编码
     */
    public String CHARSET = "utf-8";

    /**
     * 支付异步通知地址
     */
    @Value("${alipay.notifyUrl_pay}")
    public String NOTIFY_URL_PAY = "";

    //发红包异步通知地址
    @Value("${alipay.notifyUrl_fund_coupon}")
    public String NOTIFY_URL_FUND_COUPON = "";
    /**
     * 类型
     */
    public String FORMAT = "json";

    /**
     * 商户号/卖家号 seller_id
     */
    @Value("${alipay.pid}")
    public String PID;

    public String VERSION = "1.0";


    /**
     * 初始化调用支付宝接口的客户端
     * @return
     */
    @Bean
    public AlipayClient getAlipayClient() {

        return new DefaultAlipayClient(SERVICE_URL, APP_ID, PRIVATE_KEY, FORMAT, CHARSET, ALI_PAY_PUBLIC_KEY, SIGN_TYPE); //获得初始化的AlipayClient

    }

}
